package pingan.com.quarter_hour.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by xsj on 2018/1/18.
 */

//获取版本号
public class VersionUtil {

    public static String getVersionName(Context context){
        //获取版本号
        PackageManager packageManager = context.getPackageManager();
        String versionName="1.0";
        try {
            PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
            versionName = packageInfo.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionName;
    }
}
